function isUndef (val) {
  return (val === void 0) || val === null
}
let str = ''
let str1 = 'xxx'
let str2 = undefined
let str3 = null
console.log(isUndef(str));
console.log(isUndef(str1));
console.log(isUndef(str2));
console.log(isUndef(str3));
/**
 * 数组转哈希表
 * @param {} array 
 * @returns 
 */
function arrayToHash (array) {
  let hash = {}
  for (let i = 0, len = array.length; i < len; i++) {
    hash[array[i]] = true
  }
  return hash
}
function searchAttr (val) {
  let obj = arrayToHash(['pop', 'push', 'slice'])
  for (let key in obj) {
    if (key === val) {
      console.log('数组上存在这个属性:', val);
      break
    }
  }

}
// console.log(searchAttr('push'));
// 作用是判断一个值是否已定义，即不为 undefined。
export function isDef (v) {
  return v !== undefined && v !== null
}